/**
 * 产品图片
 */
module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, DATE, STRING } = Sequelize;

    await queryInterface.createTable('image', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      uuid: { type: STRING(36), unique: true },
      name: STRING(255),
      fk_product: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'product',
          },
          key: 'uuid',
        }, // 所属产品
      },
      createdAt: DATE,
      updatedAt: DATE,
    });
  },

  down: async queryInterface => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('image');
  }
};
